import request from '@/utils/request'

export default {
  // 组合条件查询每门课程下对应的目录数
  getCourseOverview(current, limit, CourseOverviewQuery) {
    return request({
      url: `/categories/getCourseOverview/${current}/${limit}`,
      method: 'post',
      data: CourseOverviewQuery
    })
  },
  // 拖拽改变目录次序
  updateSequence(newIndex, currRow) {
    return request({
      url: `/categories/updateCategoryPosition/${newIndex}`,
      method: 'post',
      data: currRow
    })
  },
  // 组合条件查询课程信息
  getCategoriesPage(current, limit, courseQueryObj) {
    return request({
      url: `/categories/pageCategoriesCondition/${current}/${limit}`,
      method: 'post',
      data: courseQueryObj
    })
  },
  // 删除该目录，及该目录下的所有子信息
  deleteCategory(categoryId) {
    return request({
      url: `/categories/deleteCategories/${categoryId}`,
      method: 'delete'
    })
  },
  // 修改课程信息
  updateCategory(category) {
    return request({
      url: `/categories/updateCategory`,
      method: 'put',
      data: category
    })
  },
  // 增加新的课程
  addCategory(category) {
    return request({
      url: `/categories/addCategory`,
      method: 'post',
      data: category
    })
  },
  // 根据目录id查询关联目录列表
  getNextCategoryList(categoryId) {
    return request({
      url: `/categoriesRelation/getNextCategoryList/${categoryId}`,
      method: 'get'
    })
  },
  // 根据目录id查询可以添加的关联目录列表
  getCanBeAddedNextCategoryList(currentCategoryId, courseId) {
    return request({
      url: `/categoriesRelation/getCanBeAddedNextCategoryList/${currentCategoryId}/${courseId}`,
      method: 'get'
    })
  },
  // 增加新的关联目录
  addCategoryRelation(nextCategory) {
    return request({
      url: `/categoriesRelation/addCategoryRelation`,
      method: 'post',
      data: nextCategory
    })
  },
  // 删除关联目录
  deleteCategoryRelation(categoryId, nextCategoryId) {
    return request({
      url: `/categoriesRelation/deleteCategoryRelation/${categoryId}/${nextCategoryId}`,
      method: 'delete'
    })
  },
  // 根据课程id查询对应的目录列表
  getCategoriesInfoByCourseId(courseId) {
    return request({
      url: `/categories/getCategoriesInfoByCourseId/${courseId}`,
      method: 'get'
    })
  }
}
